<template>
	<view>
		<view class="main">
			<scroll-view scroll-y="true" class="left">
				<view class="tab">
					<view class="tab-item center" v-for="(item, index) in lineList" 
					:class="activeIndex === index ? 'active' : ''" @click="tabChange(index)">
						{{item.lineName}}
					</view>
				</view>
			</scroll-view>
			<view class="right">
				<image :src="$baseUrl + picture.imgUrl" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				lineList: [],
				activeIndex: 0,
				picture: () => {}
			};
		},
		onLoad() {
			this.getline()
			this.getPicture()
		},
		methods:{
			getline(){
				this.$request({
					url: '/prod-api/api/metro/line/list'
				}).then(res => {
					console.log(res)
					this.lineList = res.data
				})
			},
			tabChange(index){
				this.activeIndex = index
				uni.showToast({
					title:`${this.lineList[this.activeIndex].lineName}亮了`
				})
			},
			getPicture(){
				this.$request({
					url: '/prod-api/api/metro/city'
				}).then(res => {
					console.log(res)
					this.picture = res.data
				})
			}
		}
	}
</script>

<style lang="scss">
page{
	height: 100%;
	view{
		height: 100%;
		display: flex;
		flex-direction: column;
		.main{
			flex: 1;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			.left{
				width: 200rpx;
				background-color: #f7f7f7;
				flex-shrink: 0;
				.tab{
					display: flex;
					flex-direction: column;
					.tab-item{
						height: 96rpx;
						padding: 20rpx;
						color: #666;
						position: relative;
						&::before{
							position: absolute;
							content: '';
							width: 50%;
							left: 25%;
							bottom: 0;
							border-top: 2rpx solid #e4e7ed;
						}
					}
					.active{
						color: #dd6161;
						font-size: 36rpx;
						font-weight: bold;
						&::after{
							position: absolute;
							content: '';
							width: 6rpx;
							height: 100%;
							background-color: #dd6161;
							left: 0;
							top: 0;
						}
					}
				}
			}
			.right{
				flex: 1;
				image{
					width: 100%;
				}
			}
		}
	}
}
</style>
